<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<!-- Mirrored from www.zi-han.net/theme/hplus/login_v2.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:49 GMT -->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name=”renderer” content=”webkit”>
    <meta http-equiv=”X-UA-Compatible” content=”IE=Edge,chrome=1″ >
    <title> 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="../resources/plugins/h+/css/bootstrap.min.css" rel="stylesheet">
    <link href="../resources/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="../resources/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="../resources/plugins/h+/css/style.min.css" rel="stylesheet">
    <link href="../resources/plugins/h+/css/login.min.css" rel="stylesheet">

</head>
<body class="gray-bg">

<div class="middle-box text-center loginscreen   animated fadeInDown">
    <div>
        <div>

            <%--<h1 class="logo-name"></h1>--%>

        </div>
        <h3>积分开放平台</h3>
        <%--<p>创建一个H+新账户</p>--%>
        <form class="m-t"  onsubmit="return  false" id="registForm">
            <div class="form-group">
                <input type="text" class="form-control" name="loginName" placeholder="请输入用户名">
            </div>
            <div class="form-group">
                <input type="text" class="form-control" name="phone" placeholder="请输入手机号" >
            </div>
            <div class="form-group">
                <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码" >
            </div>
            <div class="form-group">
                <input type="password" class="form-control" name="rePassword" placeholder="请再次输入密码" >
            </div>
            <%--<div class="form-group text-left">--%>
                <%--<div class="checkbox i-checks">--%>
                    <%--<label class="no-padding">--%>
                        <%--<div class="icheckbox_square-green" style="position: relative;"><input type="checkbox" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins></div><i></i> 我同意注册协议</label>--%>
                <%--</div>--%>
            <%--</div>--%>
            <button type="submit" class="btn btn-primary block full-width m-b" >注 册</button>

            <p class="text-muted text-center"><small>已经有账户了？</small><a href="${pageContext.request.contextPath}/login/login_v2.jsp">点此登录</a>
            </p>

        </form>
    </div>
</div>
<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>


<script>

    $(function(){
        $("#registForm").validate({
            submitHandler : function() {
                doSubmit();
            },
            rules:{
                loginName:{
                    required:true,
                    maxlength:50
                },
                phone:{
                    required:true,
                    checkPhone:true
                },
                password:{
                    required:true,
                    maxlength:20
                },
                rePassword:{
                    required:false,
                    maxlength:20,
                    equalTo: "#password"
                }

            },
            messages:{
                loginName:{
                    required:"*必填！",
                    maxlength:"*长度不能超过50位！"
                },
                phone:{
                    required:"*必填！"
                },
                password:{
                    required:"*必填！",
                    maxlength:"*长度不能超过20位！"
                },
                rePassword:{
                    required:"*必填！",
                    maxlength:"*长度不能超过20位！",
                    equalTo:"*两次密码不一致"
                }
            },
            //是否在获取焦点时验证
            onfocusout:true,
            //是否在敲击键盘时验证
            //onkeyup:false,
            //提交表单后，（第一个）未通过验证的表单获得焦点
            focusInvalid:false,
            //当未通过验证的元素获得焦点时，移除错误提示
            focusCleanup:false
        });

        //自定义正则表达示验证方法
        $.validator.addMethod("checkPhone",function(value,element,params){
            var checkPhone = /^1[3,5,7,8]\d{9}$/;
            return this.optional(element)||(checkPhone.test(value));
        },"*请输入正确的手机号码！");

    });


    function doSubmit()
    {
        $.ajax( {
            url:'${pageContext.request.contextPath}/user/doRegist.ac',// 跳转到 action
            data:$("#registForm").serialize(),
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.success==true) {
                    alert("操作成功！");
                    window.location.href = '${pageContext.request.contextPath}/login/login_v2.jsp';
                }else {
                    alert(data.msg);
                }
            },
            error : function() {
                alert("操作失败！");
            }
        });
    }
</script>


</body>


</html>
